package j.util.web;/**
 * Created by xxzx1 on 2014/12/23.
 */

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NumberUtils {

    public static boolean isInteger(String str) {
        if("".equals(str.trim()) || str == null){
            return false;
        }
        Pattern pattern = Pattern.compile("[0-9]*");
        Matcher isNum = pattern.matcher(str);
        if( !isNum.matches() ) {
            return false;
        }
        return true;
    }

    public static boolean isNumeric(String str) {
        if("".equals(str.trim()) || str == null){
            return false;
        }
        Pattern pattern = Pattern.compile("^[0-9]+\\.{0,1}[0-9]*$");
        Matcher isNum = pattern.matcher(str);
        if( !isNum.matches() )
        {
            return false;
        }
        return true;
    }
}
